package org.duiduo.tutorialmod.datagen;

import net.minecraft.core.HolderLookup;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import org.duiduo.tutorialmod.TutorialMod;

import java.util.concurrent.CompletableFuture;

/**
 * 资源生成器
 *
 * <pre>使用 runData 生成资源 在 generated 下可看</pre>
 * <pre>不需要放到resources目录下 在打包时候会自动移动</pre>
 *
 * @author liangze
 * @date 2024/9/18 11:34
 */
@Mod.EventBusSubscriber(modid = TutorialMod.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class DataGenerators {

    @SubscribeEvent
    public static void gatherData(GatherDataEvent event) {
        DataGenerator generator = event.getGenerator();
        PackOutput output = generator.getPackOutput();
        CompletableFuture<HolderLookup.Provider> lookupProvider = event.getLookupProvider();
        ExistingFileHelper helper = event.getExistingFileHelper();

        generator.addProvider(event.includeClient(), new ModBlockStateProvider(output, helper));
        generator.addProvider(event.includeClient(), new ModItemModelProvider(output, helper));

        ModBlockTagGenerator blockTagGenerator = generator.addProvider(event.includeServer(),
                new ModBlockTagGenerator(output, lookupProvider, helper));
        generator.addProvider(event.includeServer(), new ModItemTagGenerator(output, lookupProvider, blockTagGenerator.contentsGetter(), helper));

        generator.addProvider(event.includeClient(), new UsLanguageProvider(output, UsLanguageProvider.EN_US));
        generator.addProvider(event.includeClient(), new CnLanguageProvider(output, CnLanguageProvider.ZH_CN));
    }

}
